package com.lagou.dao.impl;

import com.lagou.dao.ArticleDao;
import com.lagou.domain.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author sjp
 * @date 2021/7/5 17:21
 * @description
 */
@Repository
public class ArticleDaoImpl implements ArticleDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     * 添加文章
     * @param article
     */
    @Override
    public void saveArticle(Article article){
        String sql = "insert into article values(null,?,?)";
//        System.out.println(article.getTitle()+"........."+article.getAuthor());
        jdbcTemplate.update(sql, article.getTitle(),article.getAuthor());
//        int i = 1/0;
//        jdbcTemplate.update(sql, article.getTitle(),article.getAuthor());
    }
}
